#include "..\\GameEngine\\GameEngine.h"
#include "BaseMenu.h"

class NetMenu : public BaseMenu, public IListener<ClickEventArgs>
{
    TextBox* m_txtIp;
    TextBox* m_txtPort;
    Button* m_btnConnect;
    Button* m_btnBack;
public:

    virtual void IListener<ClickEventArgs>::operator()(TGameObject* sender, ClickEventArgs* args)
    {
        if (m_btnConnect == sender)
        {
            GameState *newState = GameState::Find("Game");
            newState->SetParam("IP",m_txtIp->GetText());
            newState->SetParam("Port",m_txtPort->GetText());

            GameState::Switch("Game");
        }
        else if (m_btnBack == sender)
        {
            GameState::Switch("MainMenu");
        }

    }

    virtual void Initialize() 
    {      
        BaseMenu::Initialize();
        m_txtIp = CreateTextBox("", 0);
        m_txtPort = CreateTextBox("1234", 1);
        m_btnConnect = CreateButton("Connect!", 2);
        m_btnBack = CreateButton("Back", 3);
        // TODO: add creating components from xml
        //GameEngine::AddObject(m_txtIp = new TextBox(100,100,120));
        //GameEngine::AddObject(m_txtPort = new TextBox(100,150,120));    
        //Button *btn = new Button("Connect!", 100,200);
        m_btnConnect->SetListener(this);
        m_btnBack->SetListener(this);
        //GameEngine::AddObject(btn);
    }

    virtual void Deinitialize() 
    {
        BaseMenu::Deinitialize();
    }

    virtual void DoAction() 
    {
           
    }

    virtual void OnDraw() 
    {
        
    }

};